<template>
  <div class="dialog-overlay" @click.self="$emit('cancel')">
    <div class="dialog-container">
      <div class="dialog-header">
        <h3 class="dialog-title">{{ title }}</h3>
        <button class="dialog-close" @click="$emit('cancel')">
          <i class="fas fa-times"></i>
        </button>
      </div>
      <div class="dialog-content">
        <slot></slot>
      </div>
      <div class="dialog-footer">
        <button class="dialog-button dialog-cancel" @click="$emit('cancel')">取消</button>
        <button class="dialog-button dialog-confirm" @click="$emit('confirm')">确认</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Dialog',
  props: {
    title: {
      type: String,
      required: true
    }
  }
}
</script>

<style lang="less" scoped>
@import "@/styles/variables.less";

.dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog-container {
  width: 100%;
  max-width: 500px;
  background-color: white;
  border-radius: @radius-lg;
  box-shadow: @shadow-lg;
  overflow: hidden;
  animation: dialog-fade-in 0.3s;
}

.dialog-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid @gray-200;
}

.dialog-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: @gray-900;
}

.dialog-close {
  background: none;
  border: none;
  padding: 0.5rem;
  margin: -0.5rem;
  cursor: pointer;
  color: @gray-500;
  font-size: 1.25rem;
  transition: @transition;

  &:hover {
    color: @gray-700;
  }
}

.dialog-content {
  padding: 1.5rem;
}

.dialog-footer {
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  border-top: 1px solid @gray-200;
}

.dialog-button {
  padding: 0.625rem 1.25rem;
  border-radius: @radius-md;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: @transition;
  border: none;

  &.dialog-cancel {
    background-color: @gray-100;
    color: @gray-700;

    &:hover {
      background-color: @gray-200;
    }
  }

  &.dialog-confirm {
    background-color: @primary;
    color: white;

    &:hover {
      background-color: darken(@primary, 5%);
    }
  }
}

@keyframes dialog-fade-in {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
</style> 